<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in" ref="dialogBox">
      <div class="cornerComment-in-title">
        <span>{{
            type == 2 ? '教职工' : '家长'
          }}-{{ pageOption ? (pageOption.student ? pageOption.student.name : pageOption.user.realname) : '' }}-健康申报</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <el-form label-width="300px" ref="editForm" v-if="pageOption">
          <el-form-item label="姓名:">
            {{ pageOption.student ? pageOption.student.name : pageOption.user.realname }}
          </el-form-item>
          <el-form-item label="申报日期:">
            {{ pageOption.create_time }}
          </el-form-item>
          <el-form-item label="申报体温:">
            <span :style="{'color':Number(pageOption.temperature)>37.3?'red':''}"> {{ pageOption.temperature }}°C</span>
          </el-form-item>
          <el-form-item label="本人是否健康:">
            {{ pageOption.is_health == 1 ? '是' : '否' }}
          </el-form-item>
          <el-form-item label="本人健康码:">
            <viewer :images="studentPhoto" class="descimgBox" v-if="studentPhoto.length">
              <img v-for="(decImg, index) in studentPhoto" :key="index" :src="decImg" class="viewerImg">
            </viewer>
            <p v-else>未提交</p>
          </el-form-item>
          <el-form-item label="核酸检测:">
            <viewer :images="unclein" class="descimgBox" v-if="unclein.length">
              <img v-for="(decImg, index) in unclein" :key="index" :src="decImg" class="viewerImg">
            </viewer>
            <p v-else>未提交</p>
          </el-form-item>
          <el-form-item label="共同居住人行程码:">
            <viewer :images="tripCode" class="descimgBox" v-if="tripCode.length">
              <img v-for="(decImg, index) in tripCode" :key="index" :src="decImg" class="viewerImg">
            </viewer>
            <p v-else>未提交</p>
          </el-form-item>
          <!--          <el-form-item label="是否使用药品:">-->
          <!--            {{ pageOption.drugs ? pageOption.drugs : '无' }}-->
          <!--          </el-form-item>-->
          <el-form-item label="您及您的家人14天内是否从高风险地区来厦:">
            {{ pageOption.is_in == 1 ? '是' : '否' }}
          </el-form-item>
          <el-form-item label="您的共同居住人健康码是否绿码:">
            {{ pageOption.is_other_green == 1 ? '是' : '否' }}
          </el-form-item>
          <el-form-item label="共同居住人健康码:">
            <viewer :images="familyPhoto" class="descimgBox" v-if="familyPhoto.length">
              <img v-for="(decImg, index) in familyPhoto" :key="index" :src="decImg" class="viewerImg">
            </viewer>
            <p v-else>未提交</p>
          </el-form-item>
          <el-form-item label="当前是否在厦:">
            {{ pageOption.is_local == 1 ? '是' : '否' }}
          </el-form-item>
          <el-form-item label="是否接种疫苗:">
            {{ pageOption.is_vaccines == 1 ? '是' : '否' }}
          </el-form-item>
          <el-form-item label="近期是否有出入境记录:">
            {{ pageOption.is_exit == 1 ? '是' : '否' }}
          </el-form-item>
          <el-form-item label="近期是否有出入境申请记录:">
            {{ pageOption.exit_log ? pageOption.exit_log : '无' }}
          </el-form-item>
        </el-form>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click="closePOpup" size="small">确定</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import {yearDay} from '@/utils/util.js'

export default {
  props: ['visible', 'healthId', 'type'], // commoent 学生点评 collection 学生采集
  components: {},
  data() {
    return {
      dialogVisible: false,
      // 页数
      tableHeight: 0,
      pageOption: null,
      tripCode: [],
      studentPhoto: [],
      familyPhoto: [],
      unclein: []
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible;
      if (this.visible) {
        this.InitFn();
      } else {
        this.pageOption = '';
        this.studentPhoto = [];
        this.familyPhoto = [];
        this.tripCode = [];
        this.unclein = []
      }
    }
  },
  created() {
  },
  methods: {
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
    // 初始化
    async InitFn() {
      let data = await this.$fetch(this.api.manage.health.edit, {
        id: this.healthId
      });
      if (!data.code) {
        if (data.vo.health_code) this.studentPhoto.push(data.vo.health_code);
        if (data.vo.trip_code) this.tripCode.push(data.vo.trip_code);
        if (data.vo.qr_code) {
          let newImg = data.vo.qr_code.split(',');
          for (let i in newImg) {
            this.familyPhoto.push( newImg[i])
          }
        }
        if (data.vo.nuclein) {
          let newImg = data.vo.nuclein.split(',');
          for (let i in newImg) {
            this.unclein.push(newImg[i])
          }
        }
        data.vo.create_time = yearDay(data.vo.create_time)
        this.pageOption = data.vo
      } else {
      }
    }
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 70%;
  height: 75%;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.toolbarLine {
  text-align: center;
}

.hearder-search {
  display: flex;
  align-items: center;
}

.viewerImg {
  width: 100px;
}
</style>


